﻿/*
	Copyright (C) 2019 Zongming Liu <1849059316@qq.com>

	This program is free software; you can redistribute it and/or modify
	it under the terms of the GNU General Public License as published by
	the Free Software Foundation; either version 2 of the License, or
	(at your option) any later version.
	
	This program is distributed in the hope that it will be useful,
	but WITHOUT ANY WARRANTY; without even the implied warranty of
	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
	GNU General Public License for more details.
	
	You should have received a copy of the GNU General Public License along
	with this program; if not, write to the Free Software Foundation, Inc.,
	51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/

#ifndef Scene_h__
#define Scene_h__

#include "Node.h"

namespace SkyEngine2d
{
	
	class UiCore;
	
	/*!
	 \brief 游戏场景
	 \details
	*/
	class SGE_API Scene
		:public Node, public std::enable_shared_from_this<Scene>
	{
		NODE_CLASS(Scene)
	
	public:
	
		//! 析构
		/*!
		\return
		*/
		~Scene();
	
		//! 设置默认的Widget
		/*!
		\param const WidgetSharedPtr & widget 窗口指针
		\return void
		\note 场景在初始化时，已经创建 默认窗口。除非你想自己实现 DefalutWidget ，否则一般不需要手动调用该api
		*/
		void  setDefaultWidget(Widget* widget);
	
		//! 获取默认窗口
		/*!
		\return const WidgetSharedPtr &
		*/
		Widget* getDefaultWidget()const;
	
		//! 遍历场景
		/*!
		\param Render* render 渲染指针
		\return void
		*/
		void traversal(IRender* render);
	
		//! 初始化
		virtual bool init();
	
		std::shared_ptr<Scene> convertSceneSharedPtr();
	
	protected:
	
		Scene(Node* parent = nullptr);
	
		//! 场景在进入时将调用这个接口
		/*!
		\return void
		\sa  void quitScene()
		*/
		virtual void enterScene();
	
		//! 场景在退出时调用这接口 
		/*!
		\return void
		\sa void enterScene()
		*/
		virtual void quitScene();
	
		//! 访问节点
		/*!
		\param Render * render 
		\param bool parent_change_transfrom_mat 
		\return void 
		*/
		virtual void visit(IRender* render, bool parent_change_transfrom_mat) override;
	
	protected:
	
		UiCore* m_uiCore; /*!< Ui 核心. */
	
		Widget* m_defaultWidget;/*!< 默认窗口. */
	
	private:
	
	
		friend class GameWorld;
	};
}



#endif // Scene_h__
